/**
 *
 */
import Util;
import OpenApi;
import OpenApiUtil;
import EndpointUtil;

extends OpenApi;

init(config: OpenApi.Config){
  super(config);
  @endpointRule = '';
  
  checkConfig(config);
  @endpoint = getEndpoint('imp-room', @regionId, @endpointRule, @network, @suffix, @endpointMap, @endpoint);
}

function getEndpoint(productId: string, regionId: string, endpointRule: string, network: string, suffix: string, endpointMap: map[string]string, endpoint: string) throws: string{
  if (!Util.empty(endpoint)) {
    return endpoint;
  }

  if (!Util.isUnset(endpointMap) && !Util.empty(endpointMap[regionId])) {
    return endpointMap[regionId];
  }
  return EndpointUtil.getEndpointRules(productId, regionId, endpointRule, network, suffix);
}
model GetLoginTokenRequest {
  appId?: string(name='AppId', description='AppId'),
  requestParams?: {
    appUid?: string(name='AppUid', description='用户ID'),
    appKey?: string(name='AppKey', description='AppKey'),
    deviceId?: string(name='DeviceId', description='设备ID'),
  }(name='RequestParams'),
}

model GetLoginTokenShrinkRequest {
  appId?: string(name='AppId', description='AppId'),
  requestParamsShrink?: string(name='RequestParams'),
}

model GetLoginTokenResponseBody = {
  requestId?: string(name='RequestId', description='Id of the request'),
  code?: string(name='Code'),
  message?: string(name='Message'),
  result?: {
    accessToken?: string(name='AccessToken', description='登录Tokon'),
    refreshToken?: string(name='RefreshToken', description='更新Token'),
    accessTokenExpiredTime?: long(name='AccessTokenExpiredTime', description='登录Token过期时间'),
  }(name='Result'),
}

model GetLoginTokenResponse = {
  headers: map[string]string(name='headers'),
  body: GetLoginTokenResponseBody(name='body'),
}

async function getLoginTokenWithOptions(tmpReq: GetLoginTokenRequest, runtime: Util.RuntimeOptions): GetLoginTokenResponse {
  Util.validateModel(tmpReq);
  var request = new GetLoginTokenShrinkRequest{};
  OpenApiUtil.convert(tmpReq, request);
  if (!Util.isUnset(tmpReq.requestParams)) {
    request.requestParamsShrink = OpenApiUtil.arrayToStringWithSpecifiedStyle(tmpReq.requestParams, 'RequestParams', 'json');
  }
  var req = new OpenApi.OpenApiRequest{ 
    body = Util.toMap(request),
  };
  return doRPCRequest('GetLoginToken', '2021-05-15', 'HTTPS', 'POST', 'AK', 'json', req, runtime);
}

async function getLoginToken(request: GetLoginTokenRequest): GetLoginTokenResponse {
  var runtime = new Util.RuntimeOptions{};
  return getLoginTokenWithOptions(request, runtime);
}

model CreateRoomRequest {
  request?: {
    domain?: string(name='Domain', description='租户名'),
    bizType?: string(name='BizType', description='业务类型'),
    templateId?: string(name='TemplateId', description='模板id'),
    roomId?: string(name='RoomId', description='房间id'),
    title?: string(name='Title', description='房间标题'),
    notice?: string(name='Notice', description='房间公告'),
    ownerId?: string(name='OwnerId', description='房主id'),
    extension?: map[string]string(name='Extension', description='拓展字段'),
  }(name='Request'),
}

model CreateRoomResponseBody = {
  requestId?: string(name='RequestId', description='Id of the request'),
  result?: {
    roomId?: string(name='RoomId', description='房间id'),
  }(name='Result'),
  responseSuccess?: boolean(name='ResponseSuccess'),
  errorCode?: string(name='ErrorCode', description='错误码'),
  errorMsg?: string(name='ErrorMsg', description='错误信息'),
}

model CreateRoomResponse = {
  headers: map[string]string(name='headers'),
  body: CreateRoomResponseBody(name='body'),
}

async function createRoomWithOptions(request: CreateRoomRequest, runtime: Util.RuntimeOptions): CreateRoomResponse {
  Util.validateModel(request);
  var req = new OpenApi.OpenApiRequest{ 
    body = Util.toMap(request),
  };
  return doRPCRequest('CreateRoom', '2021-05-15', 'HTTPS', 'POST', 'AK', 'json', req, runtime);
}

async function createRoom(request: CreateRoomRequest): CreateRoomResponse {
  var runtime = new Util.RuntimeOptions{};
  return createRoomWithOptions(request, runtime);
}

model DestroyRoomRequest {
  request?: {
    domain?: string(name='Domain', description='租户名'),
    roomId?: string(name='RoomId', description='房间id'),
  }(name='Request'),
}

model DestroyRoomResponseBody = {
  requestId?: string(name='RequestId', description='Id of the request'),
  responseSuccess?: boolean(name='ResponseSuccess'),
  errorCode?: string(name='ErrorCode', description='错误码'),
  errorMsg?: string(name='ErrorMsg', description='错误信息'),
}

model DestroyRoomResponse = {
  headers: map[string]string(name='headers'),
  body: DestroyRoomResponseBody(name='body'),
}

async function destroyRoomWithOptions(request: DestroyRoomRequest, runtime: Util.RuntimeOptions): DestroyRoomResponse {
  Util.validateModel(request);
  var req = new OpenApi.OpenApiRequest{ 
    body = Util.toMap(request),
  };
  return doRPCRequest('DestroyRoom', '2021-05-15', 'HTTPS', 'POST', 'AK', 'json', req, runtime);
}

async function destroyRoom(request: DestroyRoomRequest): DestroyRoomResponse {
  var runtime = new Util.RuntimeOptions{};
  return destroyRoomWithOptions(request, runtime);
}

model CreateInstanceRequest {
  request?: {
    domain?: string(name='Domain', description='租户名'),
    roomId?: string(name='RoomId', description='房间id'),
    pluginId?: string(name='PluginId', description='插件ID'),
    extension?: map[string]string(name='Extension', description='拓展字段'),
  }(name='Request'),
}

model CreateInstanceResponseBody = {
  requestId?: string(name='RequestId', description='Id of the request'),
  result?: {
    instanceId?: string(name='InstanceId', description='插件实例ID'),
    extension?: map[string]string(name='Extension', description='扩展信息'),
  }(name='Result'),
  responseSuccess?: boolean(name='ResponseSuccess'),
  errorCode?: string(name='ErrorCode', description='错误码'),
  errorMsg?: string(name='ErrorMsg', description='错误信息'),
}

model CreateInstanceResponse = {
  headers: map[string]string(name='headers'),
  body: CreateInstanceResponseBody(name='body'),
}

async function createInstanceWithOptions(request: CreateInstanceRequest, runtime: Util.RuntimeOptions): CreateInstanceResponse {
  Util.validateModel(request);
  var req = new OpenApi.OpenApiRequest{ 
    body = Util.toMap(request),
  };
  return doRPCRequest('CreateInstance', '2021-05-15', 'HTTPS', 'POST', 'AK', 'json', req, runtime);
}

async function createInstance(request: CreateInstanceRequest): CreateInstanceResponse {
  var runtime = new Util.RuntimeOptions{};
  return createInstanceWithOptions(request, runtime);
}

model GetRoomDetailRequest {
  request?: {
    domain?: string(name='Domain', description='租户名'),
    roomId?: string(name='RoomId', description='房间id'),
  }(name='Request'),
}

model GetRoomDetailResponseBody = {
  requestId?: string(name='RequestId', description='Id of the request'),
  result?: {
    roomId?: string(name='RoomId', description='房间id'),
    title?: string(name='Title', description='房间标题'),
    notice?: string(name='Notice', description='房间公告'),
    ownerId?: string(name='OwnerId', description='房主id'),
    uv?: long(name='Uv', description='uv'),
    onlineCount?: long(name='OnlineCount', description='在线数'),
    pluginInstanceInfoList?: [ 
      {
        pluginId?: string(name='PluginId', description='插件id'),
        instanceId?: string(name='InstanceId', description='对应实例id'),
        createTime?: long(name='CreateTime', description='创建时间戳'),
        extension?: map[string]string(name='Extension', description='拓展字段'),
      }
    ](name='PluginInstanceInfoList', description='活跃插件列表'),
  }(name='Result'),
  responseSuccess?: boolean(name='ResponseSuccess'),
  errorCode?: string(name='ErrorCode', description='错误码'),
  errorMsg?: string(name='ErrorMsg', description='错误信息'),
}

model GetRoomDetailResponse = {
  headers: map[string]string(name='headers'),
  body: GetRoomDetailResponseBody(name='body'),
}

async function getRoomDetailWithOptions(request: GetRoomDetailRequest, runtime: Util.RuntimeOptions): GetRoomDetailResponse {
  Util.validateModel(request);
  var req = new OpenApi.OpenApiRequest{ 
    body = Util.toMap(request),
  };
  return doRPCRequest('GetRoomDetail', '2021-05-15', 'HTTPS', 'POST', 'AK', 'json', req, runtime);
}

async function getRoomDetail(request: GetRoomDetailRequest): GetRoomDetailResponse {
  var runtime = new Util.RuntimeOptions{};
  return getRoomDetailWithOptions(request, runtime);
}

model GetRoomListRequest {
  request?: {
    domain?: string(name='Domain', description='租户名'),
    bizType?: string(name='BizType', description='业务类型'),
    pageNum?: long(name='PageNum', description='查询第几页的房间列表'),
    pageSize?: long(name='PageSize', description='该页面房间数量(最大支持50)'),
  }(name='Request'),
}

model GetRoomListResponseBody = {
  requestId?: string(name='RequestId', description='Id of the request'),
  result?: {
    total?: long(name='Total', description='租户下的房间列表总数'),
    hasMore?: boolean(name='HasMore', description='是否还有下一页房间列表'),
    roomInfoList?: [ 
      {
        roomId?: string(name='RoomId', description='房间id'),
        title?: string(name='Title', description='房间标题名字'),
        ownerId?: string(name='OwnerId', description='房主的用户id'),
        bizType?: string(name='BizType', description='业务类型'),
        domain?: string(name='Domain', description='应用id，同appId'),
      }
    ](name='RoomInfoList', description='租户下的房间列表基础信息'),
  }(name='Result', description='业务结果'),
  responseSuccess?: boolean(name='ResponseSuccess', description='请求是否成功'),
  errorCode?: string(name='ErrorCode', description='错误码'),
  errorMsg?: string(name='ErrorMsg', description='错误信息'),
}

model GetRoomListResponse = {
  headers: map[string]string(name='headers'),
  body: GetRoomListResponseBody(name='body'),
}

async function getRoomListWithOptions(request: GetRoomListRequest, runtime: Util.RuntimeOptions): GetRoomListResponse {
  Util.validateModel(request);
  var req = new OpenApi.OpenApiRequest{ 
    body = Util.toMap(request),
  };
  return doRPCRequest('GetRoomList', '2021-05-15', 'HTTPS', 'POST', 'AK', 'json', req, runtime);
}

async function getRoomList(request: GetRoomListRequest): GetRoomListResponse {
  var runtime = new Util.RuntimeOptions{};
  return getRoomListWithOptions(request, runtime);
}

